const quickSort = (arr) => {
    if(arr.length < 2) return arr
    let mid = Math.floor(arr.length / 2)
    let midVal = arr.splice(mid, 1)[0]
    let left = [], right = []
    for(let item of arr) {
        if(item <= midVal) {
            left.push(item)
        }
        else {
            right.push(item)
        }
    }
    return quickSort(left).concat(midVal).concat(quickSort(right))
}
let arr = [2,3,1,4,5,6,1,4,1,2,3,56,12,21123,121,122,124,1,2,45,14,22,44,1,2,4,6,3,56,35,5]
let time = new Date().getTime()
console.log(quickSort(arr));
console.log(new Date().getTime() - time);